package com.etc.my.service.impl;


import com.etc.my.dao.SellDao;
import com.etc.my.dto.CountDto;
import com.etc.my.dto.SellDto;
import com.etc.my.entity.Sell;
import com.etc.my.service.SellService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SellServiceImpl implements SellService {

    @Autowired
    private SellDao dao;

    public SellDao getDao() {
        return dao;
    }

    public void setDao(SellDao dao) {
        this.dao = dao;
    }

    @Override
    public List<Sell> getWantSellListByUserIdOfPage(Integer userId, Integer page, Integer size) {
        return dao.queryWantSellListByUserIdOfPage(userId,page,size);
    }

    @Override
    public CountDto getWantSellCountByUserId(Integer userId) {
        return dao.queryWantSellCountByUserId(userId);
    }

    @Override
    public boolean addSellCar(SellDto sellDto) {
        if (sellDto.getSell_address()!=null&&sellDto.getSell_cardept()!=null&&sellDto.getSell_phone()!=null){
            return dao.addSellCar(sellDto);
        }
        return false;
    }

    @Override
    public boolean CancelSellCar(Integer sellid) {
        if(sellid!=null){
            return dao.deleteSellCar(sellid);
        }else{
            return false;
        }

    }

    @Override
    public boolean updateSellCar(SellDto sellDto) {
        if (sellDto.getSell_address()!=null&sellDto.getSell_phone()!=null&&sellDto.getSell_cardept()!=null){
            return dao.updateSellCar(sellDto);
        }
        return false;
    }


}
